Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for runevm contract #513

Merged
merged 1 commit into from
May 2, 2019
Merged

Initial support for runevm contract #513

merged 1 commit into from
May 2, 2019

Conversation

s1na
Copy link
Collaborator

@s1na s1na commented Apr 4, 2019

This PR adds runevm as a system contract. I wanted to be able to test runevm via testeth, and made these changes to facilitate that. Not sure if this is something that you'd want merged.

Just now when I wanted to push my branch name conflicted with https://github.com/ewasm/hera/tree/runevm and I found this commit 866e12c (Update: just saw the PR #375) which would have saved me a day! :)

Three points about the PR:

  • I couldn't get context->host->call to work, and directly use the WasmEngine to call runevm.
  • When the runevm instance was being instantiated it would cause out-of-bounds memory access so I added the module.memory.initial = 20 to avoid that. Not sure how to properly handle this.
  • Added a flag disable-interface-metering, as runevm currently measures all gas costs itself (again, not sure if this is good or not).

src/hera.cpp Outdated Show resolved Hide resolved
src/hera.cpp Outdated Show resolved Hide resolved
src/binaryen.cpp Outdated Show resolved Hide resolved
@codecov-io
Copy link

Codecov Report

Merging #513 into master will decrease coverage by 1.56%.
The diff coverage is 8%.

@@            Coverage Diff             @@
##           master     #513      +/-   ##
==========================================
- Coverage   69.85%   68.29%   -1.57%     
==========================================
  Files           7        7              
  Lines         962      984      +22     
  Branches      125      126       +1     
==========================================
  Hits          672      672              
- Misses        265      286      +21     
- Partials       25       26       +1

@codecov-io
Copy link

codecov-io commented Apr 21, 2019

Codecov Report

Merging #513 into master will decrease coverage by 0.31%.
The diff coverage is 6.06%.

@@            Coverage Diff             @@
##           master     #513      +/-   ##
==========================================
- Coverage   52.17%   51.86%   -0.32%     
==========================================
  Files           8        8              
  Lines        1311     1342      +31     
  Branches      129      130       +1     
==========================================
+ Hits          684      696      +12     
- Misses        600      619      +19     
  Partials       27       27

src/hera.cpp Outdated Show resolved Hide resolved
Copy link
Member

@axic axic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase and document the runevm flags in README.md.

src/hera.cpp Outdated Show resolved Hide resolved
@s1na s1na force-pushed the runevm-test branch 2 times, most recently from c8bd9bf to 48c8ae7 Compare April 30, 2019 09:55
@s1na
Copy link
Collaborator Author

s1na commented Apr 30, 2019

Updated, can you have a look @axic?

// This is the order of preference.
#if HERA_BINARYEN
new BinaryenEngine
BinaryenEngine::create
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chfast hmm, why did we had the static create() if we only ever used the default constructor?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember anything about it. If the default constructor works for this case it's good choice.

src/hera.cpp Show resolved Hide resolved
src/hera.cpp Outdated Show resolved Hide resolved
src/hera.cpp Outdated Show resolved Hide resolved
src/hera.cpp Outdated Show resolved Hide resolved
@@ -425,7 +505,8 @@ evmc_set_option_result hera_set_option(
if (strcmp(name, "engine") == 0) {
auto it = wasm_engine_map.find(value);
if (it != wasm_engine_map.end()) {
hera->engine = it->second();
wasmEngineCreateFn = it->second;
hera->engine = wasmEngineCreateFn();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, you were correct, .execute() is stateless at the moment. Would you mind if I remove the changes regarding the engines and merge this PR?

And then could you create a new PR changing the handling of the engine, because that might be a bug currently, but want to have @chfast's opinion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, feel free to modify the PR.

@axic axic changed the title [WIP] Initial support for runevm contract Initial support for runevm contract Apr 30, 2019
@axic axic requested a review from chfast April 30, 2019 17:15
@axic
Copy link
Member

axic commented Apr 30, 2019

@chfast can you please review this PR?

Copy link
Member

@axic axic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks OK. We can improve the engine part later.


bytes ret;
evmc_status_code status = result.isRevert ? EVMC_REVERT : EVMC_SUCCESS;
if (status == EVMC_SUCCESS && result.returnValue.size() > 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (status == EVMC_SUCCESS && result.returnValue.size() > 0)
if (status == EVMC_SUCCESS && !result.returnValue.empty())

but the returnValue is not really needed.

src/hera.cpp Outdated Show resolved Hide resolved
@axic axic merged commit 1331368 into ewasm:master May 2, 2019
@s1na s1na deleted the runevm-test branch May 2, 2019 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants